﻿using System;
using System.Web.UI;
using Bingosoft.Web.Utils;
using HHMMS.Core.Service;
using HHMMS.Core.Model;

namespace HHMMS.UI.Modules.PlanManager
{
    public partial class PurchaseSuppliesPlanEdit : FormPage
    {
        private readonly PurchaseSuppliesPlanService _purchaseSuppliesPlanService = ObjectHelper.GetObject<PurchaseSuppliesPlanService>();

        protected void Page_Load(object sender, EventArgs e)
        {            
            if (!IsPostBack)
            {
                this.tbDocId.Text = Request.GetQuery<int>("docId") + "";
                if (!SmartForm.IsInsert())
                {
                    SmartForm.Fill(container, "PlanManager.PurchaseSuppliesPlan.Get");
                    this.lbPartModel.Text = this.pickParts.Values;
                }
            }
        }
        
        protected void SaveOrUpdatePurchaseSuppliesPlan(object sender, EventArgs e)
        {
            PurchaseSuppliesPlan purchaseSuppliesPlan = SmartForm.GetEntity<PurchaseSuppliesPlan>(container);
            this._purchaseSuppliesPlanService.SaveOrUpdatePurchaseSuppliesPlan(purchaseSuppliesPlan);

            ScriptHelper.CloseDialog(this, "true");
        }
    }
}